home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / basic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-30  |  1.7 KB  |  72 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for Basic subroutines (SUB or PROCEDURE). Scan
  17.   handlers are plain functions (LoadSeg'ed by GED): no standard C startup code,
  18.   no library calls.
  19.   
  20.   DICE-C:
  21.   
  22.   dcc basic.c -// -l0 -md -mRR -o ram:basic
  23.  
  24.   ------------------------------------------------------------------------------
  25. */
  26.  
  27. #include <exec/types.h>
  28.  
  29. ULONG
  30. ScanHandlerBasic(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  31. {
  32.     const char *version = "$VER: Basic 1.0 (" __COMMODORE_DATE__ ")";
  33.  
  34.     if (len > 4) {
  35.  
  36.         if (**text == 'S') {
  37.  
  38.             if (((*text)[1] == 'U') && ((*text)[2] == 'B') && ((*text)[3] == ' ')) {
  39.  
  40.                 // found SUB subroutine
  41.  
  42.                 *text += 4;
  43.  
  44.                 return(len - 4);
  45.             }
  46.         }
  47.         else {
  48.  
  49.             if (**text == '>') {
  50.  
  51.                 *text += 2;
  52.                 len   -= 2;
  53.             }
  54.  
  55.             if ((len > 10) && (**text == 'P')) {
  56.  
  57.                 if (((*text)[1] == 'R') && ((*text)[2] == 'O') && ((*text)[3] == 'C') && ((*text)[4] == 'E') && ((*text)[5] == 'D') && ((*text)[6] == 'U') && ((*text)[7] == 'R') && ((*text)[8] == 'E') && ((*text)[9] == ' ')) {
  58.  
  59.                     // found PROCEDURE
  60.  
  61.                     *text += 10;
  62.  
  63.                     return(len - 10);
  64.                 }
  65.             }
  66.         }
  67.     }
  68.  
  69.     return(FALSE);
  70. }
  71.  
  72.